/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package com.mcet;

import java.sql.Connection;
import java.sql.DatabaseMetaData;

import java.sql.DriverManager;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.ResultSetMetaData;
import java.sql.SQLException;
import java.sql.Statement;
import java.util.logging.Level;
import java.util.logging.Logger;

/**
 *
 * @author dell
 */
public class LargeSetData {
    
    
    private String sqlServer = "localhost";
    private int port = 3306;
    private String dbUser = "root";
    private String dbPassword = "root";
    private String dbpath = "outliers";
    private String tableName = "disease";

    
    private String organ[] ={"eye",
        "ear",
        "heart",
        "head",
        "spine",
        "leg",
        "veins",};
    
    private String disease1[] = {"night blindness","ear infection","heart attack","meningitis","spondylopathy",
    "sprains","varicose veins"}; 
    
    private String disease2[] = {"glaucoma","tinnitus","aneurysm","encephalitis","back pain",
    "strains","phlebitis"};
    
    private String disease3[] = {"cataracts","barotrauma","atherosclerosis","brain abscess","spinal curvature",
    "fracture","dvt"}; 
    
    private String disease4[] = {"crossed eyes","otitis media","high blood pressure","seizures","torticollis",
    "vericose veins","thrombosis"}; 
    
    private String disease5[] = {"lazy eye","otosclerosis","angina","trauma","discitis",
    "numbness","blood clots"}; 
    
    private String disease6[] = {"low vision","ear cancer","low blood pressure","concussion","pott disease",
    "warts","artheritics"};

    public LargeSetData() {
    }
    
    
    public void insertFakeData() {
        
        Connection con = null;
        PreparedStatement ps = null;
        String query = "insert into disease (organ, disease1,disease2,disease3,disease4,disease5,disease6) values (?,?,?,?,?,?,?)";
        
        try {
            try {
                Class.forName("com.mysql.jdbc.Driver").newInstance();
            } catch (Exception ex) {
                Logger.getLogger(LargeSetData.class.getName()).log(Level.SEVERE, null, ex);
            }
            con = DriverManager.getConnection("jdbc:mysql://" + sqlServer + ":" + port
                    + "/" + dbpath, dbUser, dbPassword);
            
            
            ps = con.prepareStatement(query);
             
            long start = System.currentTimeMillis();
            for(int i =0; i<10;i++){
                ps.setString(1,organ[i%6]);
                ps.setString(2, disease1[i%6]);
                ps.setString(3, disease2[i%6]);
                ps.setString(4, disease3[i%6]);
                ps.setString(5, disease4[i%6]);
                ps.setString(6, disease5[i%6]);
                ps.setString(7, disease6[i%6]);
               
                
                 
                ps.addBatch();
                 
                if(i%10 == 0) ps.executeBatch();
                
            }
            ps.executeBatch();
             
            System.out.println("Time Taken="+(System.currentTimeMillis()-start));
             
        } catch (SQLException e) {
            e.printStackTrace();
        }finally{
            try {
                ps.close();
                con.close();
            } catch (SQLException e) {
                e.printStackTrace();
            }
        }
    }
    }
    
    
    
    
    
    
    

